package com.leetcode.LC;

import java.util.Arrays;

public class LC1337 {
    public int[] kWeakestRows(int[][] mat, int k) {
        //战斗值*100 + 行号，然后排序，排完序后再对100取余
        int[] ints = new int[mat.length];
        int count;
        for (int i = 0; i < mat.length; i++) {
            count = 0;
            for (int j = 0; j < mat[0].length; j++) {
                if (mat[i][j] == 1) {
                    count++;
                } else {
                    break;
                }
            }
            ints[i] = count * 100 + i;
        }
        Arrays.sort(ints);
        int[] ints1 = new int[k];
        for (int i = 0; i < k; i++) {
            ints1[i]=ints[i]%100;
        }
        return ints1;
    }


}
